/*
 *  Copyright 2010 asustatil.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package edu.upf.network.impl;

import edu.upf.network.ContentTransfer;
import edu.upf.utils.Definitions;
import org.jivesoftware.smackx.filetransfer.IncomingFileTransfer;

/**
 *
 * @author asustatil
 */
public class IncomingContentTransfer implements ContentTransfer, Definitions {
    IncomingFileTransfer transfer;
    
    public IncomingContentTransfer(IncomingFileTransfer transfer){
        this.transfer=transfer;
    }

    @Override
    public boolean isDone(){
        return transfer.isDone();
    }

    @Override
    public int getProgress(){
        return (int)Math.round(transfer.getProgress()*100);
    }

    @Override
    public String getType() {
        return "Incoming";
    }

    @Override
    public String getContentName() {
        return transfer.getFileName();
    }

    @Override
    public String getContentOwner() {
        return transfer.getPeer();
    }

    @Override
    public String getContentSize() {
        return transfer.getFileSize()/1000 + " KB";
    }

    @Override
    public String getContentStatus() {
        if(transfer.isDone()){
            return FINISHED;
        }else{
            return DOWNLOADING;
        }
    }
}
